package com.tyk.bookstore.back.platform.model.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tyk
 * @description 行政区域
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AreaSimVo {

    @Schema(description = "行政区划代码")
    private Long code;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "下级行政区")
    private List<AreaSimVo> children;

    public AreaSimVo(Long code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 条件子结点
     */
    public void addChild(AreaSimVo vo) {
        if (this.children == null) this.children = new ArrayList<>();
        this.children.add(vo);
    }
}
